import request from '@/router/axios';
import qs from 'qs';

export const getList = (current, size, params) => {
    return request({
        url: '/api/mes-admin/shift/page',
        method: 'get',
        params: {
            ...params,
            current,
            size
        }
    });
};

export const getDetail = (shiftId) => {
    return request({
        url: '/api/mes-admin/shift/detail',
        method: 'get',
        params: {
            shiftId: shiftId
        }
    });
};

export const remove = (ids) => {
    return request({
        url: '/api/mes-admin/shift/remove',
        method: 'post',
        params: {
            ids
        }
    });
};

export const add = (row) => {
    return request({
        url: '/api/mes-admin/shift/submit',
        method: 'post',
        data: row
    });
};

export const update = (row) => {
    return request({
        url: '/api/mes-admin/shift/submit',
        method: 'post',
        data: row
    });
};

export const getTableList = (params, searchQuery) => {
    return request({
        url: '/api/mes-admin/shift/page',
        method: 'get',
        params: {
            current: params.current,
            size: params.size,
            ...searchQuery
        }
    });
};
export const getTableDetail = (id) => {
    return request({
        url: '/api/mes-admin/shift/detail',
        method: 'get',
        params: {
            id
        }
    });
};

export const postTableDetail = (ids) => {
    return request({
        url: '/api/mes-admin/shift/remove?ids=' + ids,
        method: 'post'
    });
};

export const postAddData = (params) => {
    return request({
        url: '/api/mes-admin/shift/submit',
        method: 'post',
        data: {
            ...params
        }
    });
};

export const exportTableData = (params) => {
    return request({
        url: '/api/mes-product/shift/export-template',
        responseType: 'arraybuffer',
        params: {
            params
        }
    });
};

export const getShfitType = () => {
    return request({
        url: '/api/blade-system/dict/dictionary?code=shift_type',
        method: 'get',
        params: {}
    });
};
